package com.freshcity.page.common
{
	import com.freshcity.common.UserInfoBack;
	import com.freshcity.component.container.Component;
	import com.freshcity.utils.MessageUtil;
	import com.freshcity.utils.StringUtil;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.TextEvent;

	public class UserItem extends Component
	{
		public var data:*;
		private var back:UserInfoBack;
		private var online:OnlineIcon;

		public function UserItem(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0)
		{
			super(parent, xpos, ypos);
			this.addEventListener(Event.REMOVED_FROM_STAGE,dispose);
		}

		override protected function addChildren():void
		{
			super.addChildren();
			back=new UserInfoBack();
			addChild(back);
			
			online = new OnlineIcon(back,375.25,2.55);
		}

		override public function draw():void
		{
			super.draw();

			back.sexIcon.gotoAndStop(data.sex);
			online.online = (data.online != null);
			//back.incomeIcon.setValue(data.income);
			//back.incomeIcon.toolTipData='美誉度';
			back.desc.text=data.selfDesc;

			back.nameLabel.text = data.id;
			back.ageLabel.text = MessageUtil.decodeAge(data.birthYear)+"岁";
			if(data.location)back.addressLabel.text = data.location;
			back.levelLabel.text = MessageUtil.decodeLevel(int(data.level));
			
			back.linkLabel.styleSheet=StringUtil.style;
			back.linkLabel.selectable=true;
			back.linkLabel.htmlText="".concat("<a href='event:", data.id, "'>", '>>详细', "</a>");
			back.addEventListener(TextEvent.LINK, main.onAboutUser, false, 0, true);
		}
		
		private function dispose(evt:Event):void
		{
			//back.incomeIcon.toolTipData=null;
			//ToolTipsManager.unregister(back.incomeIcon);
		}

	}
}
